/* Ejercicio 3.18
   ejer3_18.c
*/
#include <stdio.h>

/* funcion main, el programa inicia aca */
int main( void )
{
    int account;
    float initialbalance, charged, credits, limit, newbalance;

    printf( "Enter account number (-1 to end): " );
    scanf( "%d", &account );

    while ( account != - 1 ) {
        printf( "Enter beginning balance: " );
        scanf( "%f", &initialbalance );
        printf( "Enter total charges: " );
        scanf( "%f", &charged );
        printf( "Enter total credits: " );
        scanf( "%f", &credits );
        printf( "Enter credit limit: " );
        scanf( "%f", &limit );

        newbalance = initialbalance + charged - credits;

        if ( newbalance > limit ) {
            printf( "Account:       %d\n", account );
            printf( "Credit limit:  %.2f\n", limit );
            printf( "Balance:       %.2f\n", newbalance );
            printf( "Credit Limit Exceeded.\n" );
        }

        printf( "\nEnter account number (-1 to end): " );
        scanf( "%d", &account );
    }
	return 0;
} /* fin de la funcion main */
